import React, { Component } from 'react'
import { CountConsumer } from '../../countStore'

export default class CountBtn extends Component {
    render() {
        return (
            <CountConsumer>
                {
                    (arg) => {
                        const handler = this.props.type === 'increment' ? arg.onIncrementCount : arg.onDecrementCount
                        return <button onClick={handler}>{this.props.children}</button>
                    }
                }
            </CountConsumer>
        )
    }
}
